package daybook.io.args;

import com.beust.jcommander.IParameterValidator;
import com.beust.jcommander.ParameterException;

import java.time.LocalDate;
import java.time.format.DateTimeParseException;

public class LocalDateValidator implements IParameterValidator {
    @Override
    public void validate(String name, String value) throws ParameterException {
        try {
            LocalDate.parse(value);
        } catch (DateTimeParseException e) {
            throw new ParameterException("bad date format", e);
        }
    }
}
